﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Text;
using Maticsoft.Common;
using LTP.Accounts.Bus;
namespace ZGEDrySaltery.Web.object_category
{
    public partial class Add : Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
                       
        }

        		protected void btnSave_Click(object sender, EventArgs e)
		{
			
			string strErr="";
			if(!PageValidate.IsNumber(txtPCID.Text))
			{
				strErr+="PCID格式错误！\\n";	
			}
			if(this.txtNAME.Text.Trim().Length==0)
			{
				strErr+="NAME不能为空！\\n";	
			}
			if(this.txtPINYIN.Text.Trim().Length==0)
			{
				strErr+="PINYIN不能为空！\\n";	
			}
			if(this.txtALIAS.Text.Trim().Length==0)
			{
				strErr+="ALIAS不能为空！\\n";	
			}
			if(!PageValidate.IsNumber(txtPREPCID.Text))
			{
				strErr+="PREPCID格式错误！\\n";	
			}
			if(!PageValidate.IsNumber(txtSORT.Text))
			{
				strErr+="SORT格式错误！\\n";	
			}
			if(!PageValidate.IsDateTime(txtINSERTTIME.Text))
			{
				strErr+="INSERTTIME格式错误！\\n";	
			}
			if(!PageValidate.IsDateTime(txtMODIFYTIME.Text))
			{
				strErr+="MODIFYTIME格式错误！\\n";	
			}

			if(strErr!="")
			{
				MessageBox.Show(this,strErr);
				return;
			}
			int PCID=int.Parse(this.txtPCID.Text);
			string NAME=this.txtNAME.Text;
			string PINYIN=this.txtPINYIN.Text;
			string ALIAS=this.txtALIAS.Text;
			int PREPCID=int.Parse(this.txtPREPCID.Text);
			int SORT=int.Parse(this.txtSORT.Text);
			DateTime INSERTTIME=DateTime.Parse(this.txtINSERTTIME.Text);
			DateTime MODIFYTIME=DateTime.Parse(this.txtMODIFYTIME.Text);

			ZGEDrySaltery.Model.object_category model=new ZGEDrySaltery.Model.object_category();
			model.PCID=PCID;
			model.NAME=NAME;
			model.PINYIN=PINYIN;
			model.ALIAS=ALIAS;
			model.PREPCID=PREPCID;
			model.SORT=SORT;
			model.INSERTTIME=INSERTTIME;
			model.MODIFYTIME=MODIFYTIME;

			ZGEDrySaltery.BLL.object_category bll=new ZGEDrySaltery.BLL.object_category();
			bll.Add(model);
			Maticsoft.Common.MessageBox.ShowAndRedirect(this,"保存成功！","add.aspx");

		}


        public void btnCancle_Click(object sender, EventArgs e)
        {
            Response.Redirect("list.aspx");
        }
    }
}
